﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using QFlow.Core;

namespace QFlow.Data
{
    public static class UserExtension
    {
        public static bool AuthenticateUser(this Table<User> queriable, string userName, string userPassword, out User user)
        {
            user = queriable.Where(t => t.Password == userPassword && t.Username == userName).SingleOrDefault();
            return user != null;
        }

        public static User GetCurrentUser(this Table<User> queriable)
        {
            return queriable.Single(u => u.UserID == (Authentication.CurrentUser as User).UserID);
        }
    }
}
